//============================================================
// Producnt name:		Wz
// Version: 			1.0
// Coded by:			Wz (13066628480@163.com)
// Auto generated at: 	2016/10/14 15:35:50
//============================================================

using System;
using System.Collections.Generic;
using System.Text;
using Cloud.Model;
using System.Data.SqlClient;
using System.Data;
namespace Cloud.DAL
{
	public static class ZS_INFOService
	{
		#region SqlCommandText
		private const string Save_CommandText = "insert into ZS_INFO values(@ID,@TYPEID,@UNITID,@SBDATE,@SBUSER,@SBLEADER,@TITLE,@NOTE,@ZSSTATUS,@ATTACHMENT)";
		private const string Update_CommandText = "Update ZS_INFO set TYPEID = @TYPEID,UNITID = @UNITID,SBDATE = @SBDATE,SBUSER = @SBUSER,SBLEADER = @SBLEADER,TITLE = @TITLE,NOTE = @NOTE,ZSSTATUS = @ZSSTATUS,ATTACHMENT = @ATTACHMENT where ID = @ID";
		private const string Delete_CommandText = "delete from ZS_INFO where ID = @ID";
		private const string FindAll_CommandText = "select * from ZS_INFO";
		private const string FindById_CommandText = "select * from ZS_INFO where ID=@ID";
		#endregion
		
		#region ??
		
		#endregion
		
		#region ??
		
		#endregion
		
		#region Save
		public static int Save(ZS_INFO zS_INFO)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@ID",SqlDbType.Int),
				new SqlParameter("@TYPEID",SqlDbType.VarChar),
				new SqlParameter("@UNITID",SqlDbType.VarChar),
				new SqlParameter("@SBDATE",SqlDbType.VarChar),
				new SqlParameter("@SBUSER",SqlDbType.VarChar),
				new SqlParameter("@SBLEADER",SqlDbType.VarChar),
				new SqlParameter("@TITLE",SqlDbType.VarChar),
				new SqlParameter("@NOTE",SqlDbType.Text),
				new SqlParameter("@ZSSTATUS",SqlDbType.VarChar),
				new SqlParameter("@ATTACHMENT",SqlDbType.VarChar)
				};
			pars[0].Value=zS_INFO.ID;
			pars[1].Value=zS_INFO.TYPEID;
			pars[2].Value=zS_INFO.UNITID;
			pars[3].Value=zS_INFO.SBDATE;
			pars[4].Value=zS_INFO.SBUSER;
			pars[5].Value=zS_INFO.SBLEADER;
			pars[6].Value=zS_INFO.TITLE;
			pars[7].Value=zS_INFO.NOTE;
			pars[8].Value=zS_INFO.ZSSTATUS;
			pars[9].Value=zS_INFO.ATTACHMENT;
	
			return DBHelper.ExecuteNonQuery(Save_CommandText,CommandType.Text,pars);
		}
		#endregion
		
		#region Update
		public static int Update(ZS_INFO zS_INFO)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@ID",SqlDbType.Int),
				new SqlParameter("@TYPEID",SqlDbType.VarChar),
				new SqlParameter("@UNITID",SqlDbType.VarChar),
				new SqlParameter("@SBDATE",SqlDbType.VarChar),
				new SqlParameter("@SBUSER",SqlDbType.VarChar),
				new SqlParameter("@SBLEADER",SqlDbType.VarChar),
				new SqlParameter("@TITLE",SqlDbType.VarChar),
				new SqlParameter("@NOTE",SqlDbType.Text),
				new SqlParameter("@ZSSTATUS",SqlDbType.VarChar),
				new SqlParameter("@ATTACHMENT",SqlDbType.VarChar)
				};
			pars[0].Value=zS_INFO.ID;
			pars[1].Value=zS_INFO.TYPEID;
			pars[2].Value=zS_INFO.UNITID;
			pars[3].Value=zS_INFO.SBDATE;
			pars[4].Value=zS_INFO.SBUSER;
			pars[5].Value=zS_INFO.SBLEADER;
			pars[6].Value=zS_INFO.TITLE;
			pars[7].Value=zS_INFO.NOTE;
			pars[8].Value=zS_INFO.ZSSTATUS;
			pars[9].Value=zS_INFO.ATTACHMENT;
	
			return DBHelper.ExecuteNonQuery(Update_CommandText,CommandType.Text,pars);
		}
		#endregion
		
		#region Delete
		public static int Delete(ZS_INFO zS_INFO)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@ID",SqlDbType.Int)
				};
			pars[0].Value=zS_INFO.ID;
	
			return DBHelper.ExecuteNonQuery(Delete_CommandText,CommandType.Text,pars);
		}
		#endregion
		
		#region FindAll
		public static IList<ZS_INFO> FindAll()
		{
			return CommonQuery(FindAll_CommandText,CommandType.Text,null);
		}
		#endregion
		
		#region FindById
		public static ZS_INFO FindById(Int32 iD)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@iD",SqlDbType.Int)
			};	
			pars[0].Value = iD;
			IList<ZS_INFO> list = CommonQuery(FindById_CommandText,CommandType.Text,pars);
			return list.Count > 0 ? list[0] : null;
		}
		#endregion
		
		#region ??
		
		#endregion
		
		#region ??
		
		#endregion
		
		#region CommonQuery
		private static IList<ZS_INFO> CommonQuery(string commandText, CommandType cmdType, SqlParameter[] pars)
		{
			IList<ZS_INFO> list = new List<ZS_INFO>();
			ZS_INFO zS_INFO = null;
			
			using (SqlDataReader reader = DBHelper.ExecuteQuery(commandText,cmdType,pars))
           	{
				while(reader.Read())
				{
					zS_INFO = new ZS_INFO();
					zS_INFO.ID = Convert.ToInt32(reader["ID"]);
					zS_INFO.TYPEID = Convert.ToString(reader["TYPEID"]);
					zS_INFO.UNITID = Convert.ToString(reader["UNITID"]);
					zS_INFO.SBDATE = Convert.ToString(reader["SBDATE"]);
					zS_INFO.SBUSER = Convert.ToString(reader["SBUSER"]);
					zS_INFO.SBLEADER = Convert.ToString(reader["SBLEADER"]);
					zS_INFO.TITLE = Convert.ToString(reader["TITLE"]);
					zS_INFO.NOTE = Convert.ToString(reader["NOTE"]);
					zS_INFO.ZSSTATUS = Convert.ToString(reader["ZSSTATUS"]);
					zS_INFO.ATTACHMENT = Convert.ToString(reader["ATTACHMENT"]);
					
					list.Add(zS_INFO);
				}
            }
            return list;
		}
		#endregion
		
		#region ??
		
		#endregion
		
		#region ??
		
		#endregion
	}
}



